<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>产品分类-材料首页 - 模切材料小管家</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            /* TDesign 工业品色彩系统 */
            --primary-color: #0052d9;
            --primary-light: #266fe8;
            --primary-dark: #003cab;
            --secondary-color: #f2f3ff;
            --accent-color: #e37318;
            --success-color: #00a870;
            --warning-color: #ed7b2f;
            --error-color: #d54941;
            
            /* 背景色系 */
            --bg-color-page: #f5f7fa;
            --bg-color-container: #ffffff;
            --bg-color-secondray: #f8f9fc;
            
            /* 边框和分割线 */
            --border-color: #e7e7e7;
            --border-color-light: #f0f0f0;
            --border-radius-small: 3px;
            --border-radius-medium: 6px;
            --border-radius-large: 9px;
            
            /* 文字色彩 */
            --text-primary: #1a1a1a;
            --text-secondary: #4e5969;
            --text-placeholder: #86909c;
            --text-disabled: #c9cdd4;
            
            /* 阴影系统 */
            --shadow-1: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-2: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
            --shadow-3: 0 4px 8px 0 rgba(0, 0, 0, 0.12);
            
            /* 间距系统 */
            --space-1: 4px;
            --space-2: 8px;
            --space-3: 12px;
            --space-4: 16px;
            --space-5: 20px;
            --space-6: 24px;
            --space-8: 32px;
            --space-10: 40px;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        
        body {
            background-color: var(--bg-color-page);
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        
        .container {
            max-width: 480px;
            margin: 0 auto;
            background: var(--bg-color-container);
            min-height: 100vh;
            box-shadow: var(--shadow-1);
            position: relative;
            overflow-x: hidden;
        }
        
        /* 头部样式 */
        .header {
            background: var(--primary-color);
            color: white;
            padding: var(--space-4) var(--space-4) var(--space-5);
            position: relative;
            z-index: 10;
        }
        
        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: var(--space-4);
        }
        
        .back-btn {
            font-size: 18px;
            cursor: pointer;
            opacity: 0.9;
            transition: opacity 0.2s ease;
        }
        
        .back-btn:hover {
            opacity: 1;
        }
        
        .page-title {
            font-weight: 500;
            font-size: 16px;
        }
        
        .search-btn {
            font-size: 16px;
            cursor: pointer;
            opacity: 0.9;
            transition: opacity 0.2s ease;
        }
        
        .search-btn:hover {
            opacity: 1;
        }
        
        .search-box {
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: var(--border-radius-medium);
            padding: var(--space-2) var(--space-3);
            display: flex;
            align-items: center;
            transition: all 0.2s ease;
        }
        
        .search-box:focus-within {
            background: rgba(255,255,255,0.25);
            border-color: rgba(255,255,255,0.4);
        }
        
        .search-box i {
            margin-right: var(--space-2);
            color: rgba(255,255,255,0.7);
            font-size: 14px;
        }
        
        .search-box input {
            background: transparent;
            border: none;
            color: white;
            width: 100%;
            font-size: 14px;
            outline: none;
        }
        
        .search-box input::placeholder {
            color: rgba(255,255,255,0.6);
        }
        
        /* 顶部右侧横幅 Banner */
        .header-banner {
            position: absolute;
            top: 8px;
            right: 12px;
            height: 36px;
            border-radius: 6px;
            overflow: hidden;
            box-shadow: var(--shadow-2);
        }
        .header-banner img {
            display: block;
            height: 36px;
            width: auto;
        }
        
        /* 主要内容区域 - 左右布局 */
        .main-content {
            display: flex;
            height: calc(100vh - 140px);
            overflow: hidden;
        }

        /* 右侧内容顶部 Banner（产品名称列表上方） */
        .materials-banner {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 80px; /* 提高高度，符合横幅比例 */
            margin-bottom: var(--space-4);
            border-radius: var(--border-radius-medium);
            overflow: hidden;
            box-shadow: var(--shadow-2);
            border: 1px solid var(--border-color-light);
            background: #ffffff;
        }
        .materials-banner-text {
            font-size: 16px;
            line-height: 1;
            font-weight: 600;
            color: #333333;
            letter-spacing: 0.5px;
        }
        
        /* 左侧类别导航 - 参考截图样式 */
        .category-sidebar {
            width: 100px;
            background: var(--bg-color-secondray);
            border-right: 1px solid var(--border-color-light);
            overflow-y: auto;
            flex-shrink: 0;
        }
        
        .category-item {
            padding: var(--space-4) var(--space-2);
            border-bottom: 1px solid var(--border-color-light);
            cursor: pointer;
            transition: all 0.2s ease;
            text-align: center;
            font-size: 12px;
            color: var(--text-secondary);
            position: relative;
            line-height: 1.3;
        }
        
        .category-item:hover {
            background: var(--bg-color-container);
            color: var(--text-primary);
        }
        
        .category-item.active {
            background: var(--bg-color-container);
            color: var(--primary-color);
            font-weight: 500;
        }
        
        .category-item.active::after {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: var(--primary-color);
        }
        
        /* 右侧名称列表 - 按分类显示 */
        .materials-content {
            flex: 1;
            background: var(--bg-color-container);
            overflow-y: auto;
            padding: var(--space-4);
        }
        
        .category-section {
            margin-bottom: var(--space-8);
            scroll-margin-top: var(--space-4);
        }
        
        .category-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: var(--space-4);
            padding: var(--space-3) var(--space-4);
            background: var(--secondary-color);
            border-radius: var(--border-radius-medium);
            border-left: 4px solid var(--primary-color);
        }
        
        .materials-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: var(--space-3);
            margin-bottom: var(--space-6);
        }
        
        .material-item {
            background: linear-gradient(135deg, var(--bg-color-secondray), #ffffff);
            border: 1px solid var(--border-color-light);
            border-radius: var(--border-radius-medium);
            padding: var(--space-4) var(--space-3);
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            min-height: 70px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }
        
        .material-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
            transform: scaleX(0);
            transition: transform 0.3s ease;
        }
        
        .material-item:hover {
            background: linear-gradient(135deg, var(--secondary-color), #ffffff);
            border-color: var(--primary-light);
            transform: translateY(-2px);
            box-shadow: var(--shadow-3);
        }
        
        .material-item:hover::before {
            transform: scaleX(1);
        }
        
        .material-item:active {
            transform: translateY(-1px);
        }
        
        .material-name {
            font-size: 13px;
            color: var(--text-primary);
            font-weight: 500;
            line-height: 1.4;
            word-break: break-all;
        }
        
        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: var(--space-10) var(--space-4);
            color: var(--text-placeholder);
        }
        
        .empty-state i {
            font-size: 48px;
            margin-bottom: var(--space-4);
            opacity: 0.5;
        }
        
        .empty-state p {
            font-size: 14px;
        }
        
        /* 底部导航栏 */
        .tabbar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--bg-color-container);
            border-top: 1px solid var(--border-color);
            display: flex;
            z-index: 100;
            max-width: 480px;
            margin: 0 auto;
            height: 64px;
        }
        
        .tab-item {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: var(--space-2) 0;
            cursor: pointer;
            transition: color 0.2s ease;
            color: var(--text-placeholder);
        }
        
        .tab-item.active {
            color: var(--primary-color);
        }
        
        .tab-item:hover {
            color: var(--primary-light);
        }
        
        .tab-item i {
            font-size: 18px;
            margin-bottom: var(--space-1);
        }
        
        .tab-item span {
            font-size: 10px;
        }
        
        /* 响应式设计 */
        @media (max-width: 360px) {
            .category-sidebar {
                width: 80px;
            }
            
            .category-item {
                padding: var(--space-3) var(--space-1);
                font-size: 11px;
            }
        }
        
        /* 滚动条样式 */
        .category-sidebar::-webkit-scrollbar,
        .materials-content::-webkit-scrollbar {
            width: 4px;
        }
        
        .category-sidebar::-webkit-scrollbar-track,
        .materials-content::-webkit-scrollbar-track {
            background: transparent;
        }
        
        .category-sidebar::-webkit-scrollbar-thumb,
        .materials-content::-webkit-scrollbar-thumb {
            background: var(--border-color);
            border-radius: 2px;
        }
        
        .category-sidebar::-webkit-scrollbar-thumb:hover,
        .materials-content::-webkit-scrollbar-thumb:hover {
            background: var(--text-placeholder);
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 头部区域 -->
        <div class="header">
            <div class="top-bar">
                <div class="back-btn" onclick="history.back()">
                    <i class="fas fa-arrow-left"></i>
                </div>
                <div class="page-title">产品分类-材料首页</div>
                <div class="search-btn" onclick="openSearch()">
                    <i class="fas fa-search"></i>
                </div>
            </div>
            
            <div class="search-box">
                <i class="fas fa-search"></i>
                <input type="text" placeholder="搜类别，名称，型号，公司主营业务">
            </div>
            <a class="header-banner" href="javascript:void(0)" aria-label="banner">
                <img src="https://cdn.jsdelivr.net/gh/placeholderjs/placeholder-images@latest/600x120.png?text=%E4%BC%98%E6%83%A0%E6%B4%BB%E5%8A%A8" alt="优惠活动">
            </a>
        </div>
        
        <!-- 主要内容区域 -->
        <div class="main-content">
            <!-- 左侧类别导航 -->
            <div class="category-sidebar">
                <div class="category-item active" data-category="single-tape">单面胶带</div>
                <div class="category-item" data-category="double-tape">双面胶带</div>
                <div class="category-item" data-category="protective-film">保护膜</div>
                <div class="category-item" data-category="magnetic-material">电磁屏蔽材料</div>
                <div class="category-item" data-category="absorption-material">吸波材料</div>
                <div class="category-item" data-category="optical-material">光学材料</div>
                <div class="category-item" data-category="acoustic-material">声学材料</div>
                <div class="category-item" data-category="label-material">标签材料</div>
                <div class="category-item" data-category="thermal-material">热界面材料</div>
                <div class="category-item" data-category="thin-film">薄膜</div>
                <div class="category-item" data-category="foam">泡棉</div>
                <div class="category-item" data-category="die-cut">模切辅料</div>
                <div class="category-item" data-category="leather-tape">皮胶带</div>
                <div class="category-item" data-category="insulation-paper">绝缘纸</div>
            </div>
            
            <!-- 右侧名称列表 -->
            <div class="materials-content" id="materialsContent">
                <a class="materials-banner" href="javascript:void(0)" aria-label="banner">
                    <div class="materials-banner-text">广告位 · 在此展示活动文案或促销信息</div>
                </a>
                <div id="materialsList"><!-- 动态加载所有分类的材料列表 --></div>
            </div>
        </div>
        
        <!-- 底部导航 -->
        <div class="tabbar">
            <div class="tab-item" onclick="location.href='home.html'">
                <i class="fas fa-home"></i>
                <span>首页</span>
            </div>
            <div class="tab-item" onclick="location.href='demand-list.html'">
                <i class="fas fa-search"></i>
                <span>求购</span>
            </div>
            <div class="tab-item" onclick="location.href='publish-select.html'">
                <i class="fas fa-plus-circle"></i>
                <span>发布</span>
            </div>
            <div class="tab-item" onclick="location.href='consultation.html'">
                <i class="fas fa-comments"></i>
                <span>客服</span>
            </div>
            <div class="tab-item" onclick="location.href='profile.html'">
                <i class="fas fa-user"></i>
                <span>我的</span>
            </div>
        </div>
    </div>
    
    <script>
        // 根据Excel表格数据创建材料分类数据和分类名称映射
        const materialData = {
            'single-tape': {
                name: '单面胶带',
                materials: [
                    '美纹纸胶带',
                    '醋酸布胶带',
                    '玻璃纤维胶带',
                    'PI胶带',
                    'PET胶带',
                    'PP/PE胶带',
                    '特氟龙胶带',
                    '铜箔胶带',
                    '铝箔胶带',
                    'PVC胶带'
                ]
            },
            'double-tape': {
                name: '双面胶带',
                materials: [
                    '无基材双面胶',
                    'PET双面胶',
                    '棉纸双面胶',
                    '无纺布双面胶',
                    '泡棉双面胶',
                    '纯胶膜',
                    '强粘胶带',
                    'AB胶',
                    '纳米胶',
                    '易撕胶带'
                ]
            },
            'protective-film': {
                name: '保护膜',
                materials: [
                    'PI保护膜',
                    '硅胶保护膜',
                    'PET保护膜',
                    'CPP保护膜',
                    'PE保护膜',
                    'PP保护膜',
                    'UV减粘膜'
                ]
            },
            'magnetic-material': {
                name: '电磁屏蔽材料',
                materials: [
                    '异向导电膜',
                    '单向导电膜',
                    '导电泡棉',
                    '双向导电带'
                ]
            },
            'absorption-material': {
                name: '吸波材料',
                materials: [
                    '铁氧体',
                    '导磁片',
                    'OCA',
                    '遮光胶带'
                ]
            },
            'optical-material': {
                name: '光学材料',
                materials: [
                    '偏光片',
                    '反射片',
                    '扩散片',
                    '增亮膜',
                    '背光膜',
                    '其它',
                    '纱网'
                ]
            },
            'acoustic-material': {
                name: '声学材料',
                materials: [
                    '防水透气膜',
                    '防水透声膜'
                ]
            },
            'label-material': {
                name: '标签材料',
                materials: [
                    '压敏标签',
                    '热敏标签',
                    '防伪标签',
                    '耐高温标签',
                    '遇水消失标签'
                ]
            },
            'thermal-material': {
                name: '热界面材料',
                materials: [
                    '导热垫片',
                    '导热石墨',
                    '导热泡棉',
                    '石墨烯',
                    '导热胶带'
                ]
            },
            'thin-film': {
                name: '薄膜',
                materials: [
                    'PI',
                    'PET',
                    'PC',
                    '铝箔',
                    '铜箔'
                ]
            },
            'foam': {
                name: '泡棉',
                materials: [
                    'PU泡棉',
                    'PE泡棉',
                    'EVA泡棉',
                    'EPDM泡棉',
                    'CR泡棉',
                    '硅胶胶',
                    '气凝胶',
                    '其它'
                ]
            },
            'die-cut': {
                name: '模切辅料',
                materials: [
                    '离型纸',
                    '离型膜',
                    '菲林膜',
                    '转移膜',
                    '载体膜'
                ]
            },
            'leather-tape': {
                name: '皮胶带',
                materials: [
                    '舒力克（3M）',
                    '国产'
                ]
            },
            'insulation-paper': {
                name: '绝缘纸',
                materials: [
                    '进口',
                    '国产'
                ]
            }
        };
        
        // 模拟每个材料的型号数量（实际应该从后端获取）
        function getModelCount(materialName) {
            // 根据材料名称模拟不同的型号数量
            const counts = {
                '美纹纸胶带': 15,
                '醋酸布胶带': 8,
                '玻璃纤维胶带': 12,
                'PI胶带': 25,
                'PET胶带': 18,
                'PP/PE胶带': 10,
                '特氟龙胶带': 6,
                '铜箔胶带': 14,
                '铝箔胶带': 16,
                'PVC胶带': 9,
                '无基材双面胶': 20,
                'PET双面胶': 22,
                '棉纸双面胶': 11,
                '无纺布双面胶': 13,
                '泡棉双面胶': 19,
                '纯胶膜': 7,
                '强粘胶带': 15,
                'AB胶': 8,
                '纳米胶': 5,
                '易撕胶带': 9
            };
            return counts[materialName] || Math.floor(Math.random() * 20) + 3; // 随机3-22个型号
        }
        
        // 当前选中的类别
        let currentCategory = 'single-tape';
        
        // 初始化页面
        function initPage() {
            loadAllMaterials();
            
            // 绑定类别点击事件
            document.querySelectorAll('.category-item').forEach(item => {
                item.addEventListener('click', function() {
                    const category = this.getAttribute('data-category');
                    scrollToCategory(category);
                    updateActiveCategory(category);
                });
            });
        }
        
        // 更新选中状态
        function updateActiveCategory(category) {
            if (category === currentCategory) return;
            
            document.querySelectorAll('.category-item').forEach(item => {
                item.classList.remove('active');
            });
            document.querySelector(`[data-category="${category}"]`).classList.add('active');
            
            currentCategory = category;
        }
        
        // 滚动到指定分类
        function scrollToCategory(category) {
            const categorySection = document.getElementById(`category-${category}`);
            if (categorySection) {
                categorySection.scrollIntoView({ 
                    behavior: 'smooth',
                    block: 'start'
                });
            }
        }
        
        // 加载所有材料列表
        function loadAllMaterials() {
            const materialsList = document.getElementById('materialsList');
            
            let allMaterialsHtml = '';
            
            Object.keys(materialData).forEach(categoryKey => {
                const categoryInfo = materialData[categoryKey];
                const materials = categoryInfo.materials || [];
                
                if (materials.length === 0) return;
                
                const materialsHtml = materials.map(material => {
                    return `
                        <div class="material-item" onclick="viewMaterial('${material}')">
                            <div class="material-name">${material}</div>
                        </div>
                    `;
                }).join('');
                
                allMaterialsHtml += `
                    <div class="category-section" id="category-${categoryKey}">
                        <div class="category-title">
                            <span>${categoryInfo.name}</span>
                        </div>
                        <div class="materials-grid">
                            ${materialsHtml}
                        </div>
                    </div>
                `;
            });
            
            materialsList.innerHTML = allMaterialsHtml;
        }
        
        // 查看材料详情
        function viewMaterial(name) {
            console.log('查看材料详情:', name);
            // 跳转到材料一览页面
            location.href = `product-list-material.html?category=${encodeURIComponent(name)}`;
        }
        
        // 打开搜索
        function openSearch() {
            location.href = 'search-results.html';
        }
        
        // 监听右侧滚动，更新左侧选中状态
        function observeScroll() {
            const materialsContent = document.getElementById('materialsContent');
            const categoryItems = document.querySelectorAll('.category-item');
            
            materialsContent.addEventListener('scroll', function() {
                const sections = document.querySelectorAll('.category-section');
                let currentCategory = '';
                
                // 找到当前可见的分类
                sections.forEach(section => {
                    const rect = section.getBoundingClientRect();
                    const containerRect = materialsContent.getBoundingClientRect();
                    
                    // 如果分类标题在视窗上方1/3处
                    if (rect.top <= containerRect.top + containerRect.height / 3) {
                        currentCategory = section.id.replace('category-', '');
                    }
                });
                
                // 更新左侧选中状态
                if (currentCategory && currentCategory !== this.currentCategory) {
                    categoryItems.forEach(item => {
                        item.classList.remove('active');
                    });
                    
                    const activeItem = document.querySelector(`[data-category="${currentCategory}"]`);
                    if (activeItem) {
                        activeItem.classList.add('active');
                        this.currentCategory = currentCategory;
                    }
                }
            });
        }
        
        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', function() {
            initPage();
            observeScroll();
        });
        
        // 底部导航切换
        document.querySelectorAll('.tab-item').forEach(item => {
            item.addEventListener('click', function() {
                document.querySelectorAll('.tab-item').forEach(t => t.classList.remove('active'));
                this.classList.add('active');
            });
        });
    </script>
</body>
</html>